﻿
@{
    ViewBag.Title = "EmailNoticeConfig";
    Layout = "~/Views/Shared/_LayoutMain.cshtml";
}

@section css {
    <link href="~/Assets/css/lib/bootstrap-select.css" rel="stylesheet" />
    <link href="~/Assets/css/lib/bootstrap-datetimepicker.min.css" rel="stylesheet" />
    <link href="~/Assets/css/lib/fileinput.css" rel="stylesheet" />
    <style>
        th {
            text-align: center;
            font-weight: bold;
        }

        td {
            text-align: center;
            vertical-align: middle;
        }

        #location {
            position: absolute;
            z-index: 100;
            width: 10px;
            height: 10px;
            color: red;
            font-weight: bold;
        }

        .div-relative {
            position: relative;
        }

        .div-a {
            position: absolute;
        }
    </style>
}
<div class="page-content" ng-controller="SafetyPlaceConfigController" ng-init="
     page='@(Request.QueryString["page"].IsEmpty() ? "1" : Request.QueryString["page"])';
     Id='@(Request.QueryString["Id"].IsEmpty() ? "" : Request.QueryString["Id"])';
     GetEmailTempleteList();
     GetEmailUserList();
     GetLeaderList();
     UserArray=[];
     CCArray=[];
     GetNoticeRuleDetail(Id);
     LoadingMsg='正在加载';
     ">
    <div class="load" ng-show="PageLoading">
        <div class="loader">
            <svg version="1.1" id="loader-1" x="0px" y="0px" width="100px" height="100px" viewBox="0 0 50 50" style="enable-background:new 0 0 50 50;" xml:space="preserve">
            <path fill="#000" d="M43.935,25.145c0-10.318-8.364-18.683-18.683-18.683c-10.318,0-18.683,8.365-18.683,18.683h4.068c0-8.071,6.543-14.615,14.615-14.615c8.072,0,14.615,6.543,14.615,14.615H43.935z">
            <animateTransform attributeType="xml" attributeName="transform" type="rotate" from="0 25 25" to="360 25 25" dur="0.6s" repeatCount="indefinite" />

			</path>
		</svg>
            <div class="load-msg" ng-bind="LoadingMsg"></div>
        </div>
    </div>
    <div class="page-heading">
        <h1>编辑邮件提醒规则</h1>
        <div class="options">
            <div class="btn-toolbar">

            </div>
        </div>
    </div>
    <ol class="breadcrumb">
        <li><a>系统设置</a></li>
        <li><a>邮件提醒</a></li>
        <li class="active"><a>规则设置</a></li>
    </ol>
    <form class="form-horizontal row-border">
        <div class="container-fluid">
            <div class="row">
                <div class="col-md-12">
                    <div class="panel panel-sky">
                        <div class="panel-heading"><h2>邮件提醒规则设置</h2></div>
                        <div class="panel-body">
                            <div class="form-group">
                                <label class="col-sm-1 control-label"><b style="color:red;">*</b>规则名称：</label>
                                <div class="col-sm-6">
                                    <input type="text" ng-model="EditModel.RuleName" class="form-control" placeholder="规则名称" />
                                </div>
                            </div>
                            <div class="form-group">
                                <label class="col-sm-1 control-label"><b style="color:red;">*</b>超时天数：</label>
                                <div class="col-sm-6">
                                    <input type="number" ng-model="EditModel.Days" class="form-control" placeholder="隐患超时天数" />
                                </div>
                            </div>
                            <div class="form-group">
                                <label class="col-sm-1 control-label"><b style="color:red;">*</b>收件人：</label>
                                <div class="col-sm-6">
                                    <label class="control-label" ng-show="UserArray==null || UserArray.length==0">暂未选择收件人</label>
                                    <ul class="sortable-connected list-unstyled" id="SelectedCheckList">
                                        <li class="card-task card-info" id="send_{{x.UserNo}}" ng-repeat="x in UserArray">
                                            <div class="card-handle"></div>
                                            <div class="card-title">
                                                <h3>{{x.UserName}} {{x.UserEmail}}</h3>
                                                <div class="card-done">{{$index+1}}/{{UserArray.length}}</div>
                                            </div>
                                            <div class="card-options">
                                                <div class="pull-left">
                                                </div>
                                                <div class="pull-right">
                                                    <div class="btn-group">
                                                        <a class="btn btn-default-alt btn-xs" ng-click="RemoveItems(UserArray,x);"><i class="fa fa-fw fa-times"></i></a>
                                                    </div>
                                                </div>
                                            </div>
                                        </li>
                                    </ul>
                                </div>
                                <div class="col-sm-1">
                                    <a class="btn btn-primary" data-toggle="modal" ng-click="" href="#ChooseReceiver">选择收件人</a>
                                </div>
                            </div>
                            <div class="form-group">
                                <label class="col-sm-1 control-label"><b style="color:red;">*</b>抄送人：</label>
                                <div class="col-sm-6">
                                    <label class="control-label" ng-show="CCArray==null || CCArray.length==0">暂未选择抄送人</label>
                                    <ul class="sortable-connected list-unstyled" id="SelectedCheckList2">
                                        <li class="card-task card-info" ng-repeat="x in CCArray">
                                            <div class="card-handle"></div>
                                            <div class="card-title">
                                                <h3>{{x.UserName}} {{x.UserEmail}}</h3>
                                                <div class="card-done">{{$index+1}}/{{CCArray.length}}</div>
                                            </div>
                                            <div class="card-options">
                                                <div class="pull-left">
                                                </div>
                                                <div class="pull-right">
                                                    <div class="btn-group">
                                                        <a class="btn btn-default-alt btn-xs" ng-click="RemoveItems(UserArray,x);"><i class="fa fa-fw fa-times"></i></a>
                                                    </div>
                                                </div>
                                            </div>
                                        </li>
                                    </ul>
                                </div>
                                <div class="col-sm-1">
                                    <a class="btn btn-primary" data-toggle="modal" href="#ChooseCC">选择抄送人</a>
                                </div>
                            </div>
                            <div class="form-group">
                                <label class="col-sm-1 control-label"><b style="color:red;">*</b>邮件模板：</label>
                                <div class="col-sm-6">
                                    <select class="form-control" ng-model="EditModel.EmailTempleteId" ng-change="GetTempleteContent(EditModel.EmailTempleteId);">
                                        <option value="" selected>请选择邮件模板</option>
                                        <option ng-repeat="x in TempleteList" value="{{x.Id}}">{{x.TempleteName}}</option>
                                    </select>
                                </div>
                            </div>
                            <div class="form-group">
                                <label class="col-sm-1 control-label"><b style="color:red;">*</b>模板内容：</label>
                                <div class="col-sm-6" id="EmailContent">
                                </div>
                            </div>
                            <div class="form-group">
                                <label class="col-sm-1 control-label"><b style="color:red;">*</b>立刻启用：</label>
                                <div class="col-sm-6">
                                    <label class="checkbox-inline">
                                        <input type="radio" name="chk_valid" id="IsValid" checked value="1" ng-click="EditModel.Valid==true" /> 是&nbsp;&nbsp;&nbsp;
                                    </label>
                                    <label class="checkbox-inline">
                                        <input type="radio" name="chk_valid" value="0" ng-click="EditModel.Valid==false" /> 否&nbsp;&nbsp;&nbsp;
                                    </label>
                                </div>
                            </div>
                            <div class="panel-footer">
                                <div class="col-md-2">
                                </div>
                                <div class="col-md-1">
                                    <button class="btn-primary btn" ng-click="EditEmailNotice(EditModel,page);">提交</button>
                                </div>
                                <div class="col-md-1">
                                    <a href="EmailNoticeConfigList?page={{page}}" class="btn-danger btn">返回</a>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </form>
    <div class="modal fade" id="ChooseReceiver" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
        <div class="modal-dialog" style="min-width:1050px;">
            <div class="modal-content" style="min-height: 700px;">
                <div class="modal-header">
                    <button type="button" id="close" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
                    <h2 class="modal-title">选择收件人</h2>
                </div>
                <div class="modal-body" style="min-height: 560px;">
                    <form class="form-horizontal row-border">
                        <div class="form-group">
                            <label class="col-sm-2 control-label"><b style="color:red;">*</b>责任人：</label>
                            <div class="col-sm-6">
                                <label class="checkbox-inline">
                                    <input type="checkbox" name="chk_rec" id="u_0" value="1" u-name="责任人" />责任人
                                </label>
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-2 control-label"><b style="color:red;">*</b>责任部门长：</label>
                            <div class="col-sm-6">
                                <label class="checkbox-inline">
                                    <input type="checkbox" name="chk_rec" id="u_1" value="2" u-name="责任部门部门长" />责任部门部门长
                                </label>
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-2 control-label"><b style="color:red;">*</b>安委办：</label>
                            <div class="col-sm-10">
                                <label class="checkbox-inline" ng-repeat="x in EmailUserList">
                                    <input type="checkbox" name="chk_rec" id="{{x.UserNo}}" value="3" u-name="{{x.UserName}}" ng-disabled="x.Email==null||x.Email==''" u-data="{{x.Email}}" />{{x.UserName}} {{x.Email}}
                                </label>
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-2 control-label"><b style="color:red;">*</b>领导：</label>
                            <div class="col-sm-10">
                                <label class="checkbox-inline" ng-repeat="x in LeaderList">
                                    <input type="checkbox" name="chk_rec" id="{{x.UserNo}}" u-data="{{x.Email}}" ng-disabled="x.Email==null||x.Email==''" u-name="{{x.UserName}}" value="4" />{{x.UserName}} {{x.Email}}
                                </label>
                            </div>
                        </div>
                    </form>
                </div>
                <div class="modal-footer">
                    <button class="btn-primary btn" ng-click="ChooseRec();">确认</button>
                </div>
            </div>
        </div><!-- /.modal-dialog -->
    </div>

    <div class="modal fade" id="ChooseCC" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
        <div class="modal-dialog" style="min-width:1050px;">
            <div class="modal-content" style="min-height: 700px;">
                <div class="modal-header">
                    <button type="button" id="close" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
                    <h2 class="modal-title">选择抄送人</h2>
                </div>
                <div class="modal-body" style="min-height: 560px;">
                    <form class="form-horizontal row-border">
                        <div class="form-group">
                            <label class="col-sm-2 control-label"><b style="color:red;">*</b>责任人：</label>
                            <div class="col-sm-6">
                                <label class="checkbox-inline">
                                    <input type="checkbox" name="chk_cc" id="c_0" value="1" u-name="责任人" />责任人
                                </label>
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-2 control-label"><b style="color:red;">*</b>责任部门长：</label>
                            <div class="col-sm-6">
                                <label class="checkbox-inline">
                                    <input type="checkbox" name="chk_cc" id="c_1" value="2" u-name="责任部门部门长" />责任部门部门长
                                </label>
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-2 control-label"><b style="color:red;">*</b>安委办：</label>
                            <div class="col-sm-10">
                                <label class="checkbox-inline" ng-repeat="x in EmailUserList">
                                    <input type="checkbox" name="chk_cc" id="{{x.UserNo}}" value="3" u-name="{{x.UserName}}" ng-disabled="x.Email==null||x.Email==''" u-data="{{x.Email}}" />{{x.UserName}} {{x.Email}}
                                </label>
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-2 control-label"><b style="color:red;">*</b>领导：</label>
                            <div class="col-sm-10">
                                <label class="checkbox-inline" ng-repeat="x in LeaderList">
                                    <input type="checkbox" name="chk_cc" id="{{x.UserNo}}" u-data="{{x.Email}}" u-name="{{x.UserName}}" ng-disabled="x.Email==null||x.Email==''" value="4" />{{x.UserName}} {{x.Email}}
                                </label>
                            </div>
                        </div>
                    </form>
                </div>
                <div class="modal-footer">
                    <button class="btn-primary btn" ng-click="ChooseCC();">确认</button>
                </div>
            </div>
        </div><!-- /.modal-dialog -->
    </div>

</div>


@section Js{
    <script src="~/Assets/js/pg/SafetyPlaceConfig.js?v=@DateTime.Now.ToString("yyyyMMddHH")"></script>
    <script>
        $('#SelectedCheckList').sortable({
            connectWith: ".sortable-connected",
            receive: function (event, ui) {
                var lists = $('.sortable-connected');
                for (var i = lists.length - 1; i >= 0; i--) {
                    if ($(lists[i]).children().length < 1) $(lists[i]).html('');
                };
            }
        });
        $('#SelectedCheckList2').sortable({
            connectWith: ".sortable-connected",
            receive: function (event, ui) {
                var lists = $('.sortable-connected');
                for (var i = lists.length - 1; i >= 0; i--) {
                    if ($(lists[i]).children().length < 1) $(lists[i]).html('');
                };
            }
        });
    </script>
}
